# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=ruby-rexml
_gemname=rexml
# Keep version in sync with "Bundled gems" (https://stdgems.org) for the
# packaged Ruby version.
pkgver=3.2.5
pkgrel=2
pkgdesc="An XML toolkit for Ruby"
url="https://github.com/ruby/rexml"
arch="noarch"
license="BSD-2-Clause"
depends="ruby"
checkdepends="ruby-test-unit"
makedepends="ruby-rdoc"
subpackages="$pkgname-doc"
source="https://github.com/ruby/rexml/archive/v$pkgver/$pkgname-$pkgver.tar.gz"
builddir="$srcdir/$_gemname-$pkgver"

[ "$CARCH" = "s390x" ] && options="!check"

build() {
	gem build $_gemname.gemspec
}

check() {
	ruby test/run.rb
}

package() {
	local gemdir="$pkgdir/$(ruby -e 'puts Gem.default_dir')"
	local geminstdir="$gemdir/gems/$_gemname-$pkgver"

	gem install \
		--local \
		--install-dir "$gemdir" \
		--ignore-dependencies \
		--document ri \
		--verbose \
		$_gemname

	# Remove unnecessary files and rubbish...
	cd "$gemdir"
	rm -r cache build_info extensions plugins

	cd "$geminstdir"
	rm -r doc LICENSE* *.md
}

doc() {
	pkgdesc="$pkgdesc (ri docs)"

	amove "$(ruby -e 'puts Gem.default_dir')"/doc
}

sha512sums="
9c62b789988b407bf4b02906768300b256734bfa342ef6b3551428ba2c1792b7e7e5a5480251d7df52318a5e5155757ab1377c0cc8d1d7c33278f33e367a5ca5  ruby-rexml-3.2.5.tar.gz
"
